package com.zzl.alligator.management.vote.service.impl;


import com.zzl.alligator.management.vote.mapper.VoteOptionMapper;
import com.zzl.alligator.management.vote.domain.VoteOption;
import com.zzl.alligator.management.vote.service.IVoteOptionService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * 投票选项(VoteOption)服务层
 *
 * @author zhouziliang
 * @since 2020-07-22
 */
@Service
public class VoteOptionService implements IVoteOptionService {
    
    @Autowired
    private VoteOptionMapper voteOptionMapper;
    
    /**
     * 通过ID查询单条数据
     *
     * @param optionId 主键
     * @return 实例对象
     */
    @Override
    public VoteOption findVoteOptionById(Long optionId) {
        return voteOptionMapper.findVoteOptionById(optionId);
    }

   /**
     * 通过实体作为筛选条件查询
     *
     * @param voteOption 实例对象
     * @return 对象列表
     */
    @Override
    public List<VoteOption> findVoteOptionList(VoteOption voteOption) {
        return voteOptionMapper.findVoteOptionList(voteOption);
    }

    /**
     * 新增数据
     *
     * @param voteOption 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertVoteOption(VoteOption voteOption) {
        return voteOptionMapper.insertVoteOption(voteOption);
    }

    /**
     * 修改数据
     *
     * @param voteOption 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateVoteOption(VoteOption voteOption) {
        return voteOptionMapper.updateVoteOption(voteOption);
    }

    /**
     * 通过主键删除数据
     *
     * @param optionId 主键
     * @return 是否成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteById(Long optionId) {
        return voteOptionMapper.deleteById(optionId);
    } 
    
}